from typing import List

class Solution:
    def removeElement(self, nums: List[int], val: int) -> int:
        indexh, indext, listlen = -1, 0, len(nums)
        while indext < listlen:
            if val != nums[indext]:
                indexh += 1
                nums[indexh] = nums[indext]
            indext += 1
        return indexh + 1


solution = Solution()

nums1 = [3,2,2,3]
print(nums1)
print(solution.removeElement(nums1, val=3))
print(nums1)

nums2 = [0,1,2,2,3,0,4,2]
print(nums2)
print(solution.removeElement(nums2, val=2))
print(nums2)